package com.garen.sys.dao.impl;

import com.garen.sys.dao.IFireUserGpsDao;
import com.garen.sys.entity.FireUserGps;
import com.garen.utils.MapBuilder;
import com.garen.common.BaseDao;

import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;


@Repository
public class FireUserGpsDaoImpl extends BaseDao<FireUserGps> implements IFireUserGpsDao {

	@PostConstruct
	private void init(){
		initOrm(FireUserGps.class);
	}
	
	//查询案情关联人的GPS信息
	@Override
	public List<FireUserGps> getFireUserGpsListByAjbh(String ajbh){
		String sql = "select DISTINCT t1.* from fire_user_gps t1,fire_case_record t2 " + 
				"where t1.user_id = t2.fire_man  " + 
				"and t1.gps_id in(select MAX(gps_id) from fire_user_gps tt1 GROUP BY tt1.user_id)  " + 
				"and t2.fire_ajbh = :ajbh ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("ajbh", ajbh)
				.build();
		return getListBySQL(sql,paramMap);
	}
		
}
